﻿// -----------------------------------------------------------------------
//  <copyright file="ServiceCollectionExtensions.cs" company="柳柳软件">
//      Copyright (c) 2014-2015 66SOFT. All rights reserved.
//  </copyright>
//  <site>http://www.66soft.net</site>
//  <last-editor>郭明锋</last-editor>
//  <last-date>2015-12-08 13:34</last-date>
// -----------------------------------------------------------------------

using System.Web;

using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.DataProtection;

using OSharp.Core.Dependency;

using Owin;

using ZH.JY.Identity;
using ZH.JY.Identity.Models;
using ZH.JY.Security;


namespace ZH.JY.Web
{
    public static class ServiceCollectionExtensions
    {
        /// <summary>
        /// 添加业务层服务映射信息
        /// </summary>
        public static void AddCoreServices(this IServiceCollection services, IAppBuilder app)
        {
            //Identity
            services.AddScoped<RoleManager<Role, int>, RoleManager>();
            services.AddScoped<UserManager<User, int>, UserManager>();
            services.AddScoped<SignInManager, SignInManager>();
            services.AddScoped<IAuthenticationManager>(_ => HttpContext.Current.GetOwinContext().Authentication);
            services.AddScoped<IDataProtectionProvider>(_ => app.GetDataProtectionProvider());

            //Security
            services.AddScoped<FunctionMapStore>();
            services.AddScoped<EntityMapStore>();

        }
    }
}